package com.yx.sys.controller;

import com.yx.common.vo.Result;
import com.yx.sys.entity.Adminmes;
import com.yx.sys.service.IAdminmesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/adminMes")
public class AdminMesController {

    @Autowired
    private IAdminmesService adminMesService;
    @PostMapping
    public Result<?> addAdminMes(@RequestBody Map<String,?> adminMes){
//        adminMesService.save(adminMes);
        System.out.println(adminMes);
        Adminmes adminMes1 = new Adminmes();
        adminMes1.setMessage(adminMes.get("message").toString());
        adminMes1.setATime(adminMes.get("aTime").toString());
        adminMes1.setPId((Integer) adminMes.get("pId"));
        adminMes1.setAuditorId((Integer) adminMes.get("auditorId"));
        adminMesService.save(adminMes1);
        return Result.success("提交审核意见成功");
    }

    @GetMapping("/{uId}")
    public Result<?> getAdminMesByuId(@PathVariable("uId") Integer uId){
        System.out.println("系统通知"+uId);
        List<?> list = adminMesService.getAdminMesByuId(uId);
        return Result.success(list);
    }
}
